<?php
	if ((!defined("ADMIN-AREA")) || (!in_array(SHOWVIEW,$_SESSION['access']))) {
		die("No data");
	} else {
		unset($_SESSION['access']);
	}
	
	include_once "modul/funct_stat.php";
	
	if (ACT=="edit") {
		$kode = (int) $_GET['kode'];
		$sql1 = "SELECT * FROM tbl_kategori WHERE idx='".$kode."' LIMIT 1";
		$qry1 = mysql_query($sql1);
		while ($row1 = mysql_fetch_object($qry1)) {
			$kategori = $row1->kategori;
			$tipe = $row1->tipe;
			$keterangan = $row1->keterangan;
		
		};
		
		$split = explode("-",$tanggal);
			
		$form_stat = "Edit";
	} else {
		$form_stat = "Input";
	}

	if ((ACT=="tambah") || (ACT=="edit")) {
?>
<form name="form1" method="post" action="<?php echo $path; ?>ver_kategori.php?show=<?php echo SHOW; ?>&amp;showview=<?php echo SHOWVIEW; ?>" onsubmit="MM_validateForm('<?php echo $CAT_TITLE; ?>','','R','<?php echo $CAT_TYPE; ?>','','R','<?php echo $CAT_DESC; ?>','','R');return document.MM_returnValue">
  <table width="75%" border="0" align="center" cellpadding="4" cellspacing="0">
    <tr valign="top">
      <td valign="middle"><div align="right"><?php echo $CAT_TITLE; ?></div></td>
      <td valign="middle"><div align="center">:</div></td>
      <td valign="middle"><div align="left">
        <input name="kategori" type="text" id="<?php echo $CAT_TITLE; ?>" value="<?php echo $kategori; ?>" size="32" maxlength="32" class="input-title" />
      </div></td>
    </tr>
    <tr valign="top">
      <td><div align="right"><?php echo $CAT_TYPE; ?></div></td>
      <td><div align="center">:</div></td>
      <td><div align="left">
        <input name="tipe" type="text" id="<?php echo $CAT_TYPE; ?>" value="<?php echo $tipe; ?>" size="32" maxlength="32" />
      </div></td>
    </tr>
    <tr valign="top"> 
      <td width="24%"><div align="right"><?php echo $CAT_DESC; ?></div></td>
      <td width="3%"><div align="center">:</div></td>
      <td width="73%"><div align="left">
        <textarea name="keterangan" cols="30" rows="5" id="<?php echo $CAT_DESC; ?>"><?php echo $keterangan; ?></textarea>
      </div></td>
    </tr>
    <tr> 
      <td><div align="right"></div></td>
      <td><div align="center"></div></td>
      <td><div align="left">
              <input type="submit" name="submit" id="submit" value="<?php echo $DEV_CTRL_SUBMIT; ?>" />
              <input type="reset" name="Reset" value="<?php echo $DEV_CTRL_RESET; ?>" />
        <input name="act_ver" type="hidden" id="act_ver" value="<?php echo strtolower($form_stat); ?>">
        <input name="kode" type="hidden" id="kode" value="<?php echo $kode; ?>">
      </div></td>
    </tr>
  </table>
</form>
<?php
	} else {
	if ((isset($_GET['act'])) && ($_GET['act']<>"")) {
		$act = $_GET['act'];
	} else {
		$act = "lihat";
	}
	echo $queryData->cari_form($CAT_SEARCH);
	$caridata = $queryData->cari_padaku("kategori","tipe");
?>
<table align="center" cellpadding="4" cellspacing="2" class="imagesSUB">
  <tr> 
    <th width="250" height="30" class="imagesSUB"> <div align="center"><?php echo $CAT_TITLE; ?></div></th>
    <th width="100" class="imagesSUB"><div align="center"><?php echo $CAT_TYPE; ?></div></th>
    <th width="50" class="imagesSUB" nowrap="nowrap"><div align="center"><?php echo $DEV_ACTION; ?></div></th>
  </tr>
<?php
		if (isset($_SESSION['isroot'])) {
			$sql1 = "SELECT * FROM tbl_kategori WHERE 1 ".$caridata." ORDER BY idx DESC LIMIT ".$limitdown.",10";	
		} else {
			$sql1 = "SELECT * FROM tbl_kategori WHERE 1 ".$caridata." ORDER BY idx DESC LIMIT ".$limitdown.",10";	
		}
		$qry1 = mysql_query($sql1);
		$numrow = mysql_num_rows($qry1);
		$num = 1;
		$x = 1;
		if ($numrow==0) {
			echo '<tr><th colspan="4">'.$DEV_NO_DATA.'</th></tr>';
		} else {
			while ($row1 = mysql_fetch_object($qry1)) {
				$data = $x % 2;
				if ($data==0) {
					$dataX = "ganjil";
				} else {
					$dataX = "genap";
				} 
?>
  <tr valign="top" class="<?php echo $dataX; ?>" onmouseover="setBG('bg<?php echo $x; ?>','#FFFFDD')" onmouseout="setBG('bg<?php echo $x; ?>','')" id="bg<?php echo $x; ?>"> 
    <td><?php echo $row1->kategori; ?></td>
    <td><div align="center"><?php echo $row1->tipe; ?></div></td>
		<?php echo $queryData->ctrl_data('','index.php?show='.SHOW.'&showview='.SHOWVIEW.'&act=edit&kode='.$row1->idx,$path.'ver_kategori.php?show='.SHOW.'&amp;showview='.SHOWVIEW.'&amp;kode='.$row1->idx.'&amp;act_ver=Hapus'); ?>
  </tr>
<?php
				$num++;
				$x++;
			}
		}
?>
</table>
<div align="center"><?php echo $queryData->next_prev($num,$pages_syarat,$limitdown); ?></div>
<?php
	}
?>
